﻿using System;
using System.Web.UI;
using mojoPortal.Web.RS.SBM.AppCode.Lib;

 
namespace mojoPortal.Web.RS.SBM
{
    public partial class RSEstimateDetail2 : RSBasePage
    {
        int _companyid = 0;
        int _Estimateid = 0;
        int _location = 0;

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

        }

        
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Request.QueryString["Estimateid"] != null)
                _Estimateid = Convert.ToInt32(Request.QueryString["Estimateid"].ToString());

            if (!Page.IsPostBack)
            {
                InitializeReadyServicePage();
                RSUserIdentity userIdentity = GetRSUserIdentity();
                _companyid = userIdentity.RSCompanyId;

                if (_companyid > 0)
                {
                    SetRSPageHeader("Estimate Detail");
                    if (_Estimateid > 0)
                    {
                        _location = RSSBMCommonFunctions.GetLocationIDByEstimateID(_companyid, _Estimateid);
                        ucLocationHeaderControl.LoadLocationHeader(_companyid, _location);
                        bool hasData = ucEstimateControl.LoadEstimateDataByID(_companyid, _location, _Estimateid);
                        if (hasData)
                        {
                            ucEstimateTaskListControl.LoadEstimateTaskList(_companyid, _Estimateid);
                            ucEstimatePartListControl.LoadEstimatePartListByID(_companyid, _Estimateid);
                            //ucEstimateListControl.LoadEstimateDataByEstimateID(_companyid, _Estimateid);

                            lblEstimatePart.Text = "Estimate ID: " + _Estimateid.ToString();
                            lblEstimateTask.Text = "Estimate ID: " + _Estimateid.ToString();
                        }

                    }
                }
                if (Request.QueryString["tabindex"] != null)
                    tcEstimateDetail.ActiveTabIndex = Convert.ToInt16(Request.QueryString["tabindex"].ToString());
                else
                    tcEstimateDetail.ActiveTabIndex = 0;
            }
        }

        protected void btnRunEstimateReport_Click(Object sender, EventArgs e)
        {

        }
        //protected void btnAddTask_Click(Object sender, EventArgs e)
        //{
        //    RSUserIdentity userIdentity = GetRSUserIdentity();
        //    if (userIdentity.RSCanWrite)
        //    {
        //        Response.Redirect("~/RS/SBM/RSManageEstimateTask.aspx?action=add&Estimateid=" + _Estimateid);
        //    }
        //    else
        //        ucModalActionMessageControl.ShowModal("You Do Not Have Permission To Perform This Action!", "", false);
        //}

        //protected void btnAddParts_Click(Object sender, EventArgs e)
        //{
        //    RSUserIdentity userIdentity = GetRSUserIdentity();
        //    if (userIdentity.RSCanWrite)
        //    {
        //        Response.Redirect("~/RS/SBM/RSShoppingPart.aspx?isEstimate=1&action=add&Estimateid=" + _Estimateid);
        //    }
        //    else
        //        ucModalActionMessageControl.ShowModal("You Do Not Have Permission To Perform This Action!", "", false);
            
        //}
    }
}